package com.daocao.jy.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;
import android.widget.TextView;

import com.daocao.jy.R;
import com.daocao.jy.base.BaseActivity;
import com.daocao.jy.fragment.CommissionOrderFragment;
import com.daocao.jy.fragment.MyCommissionFragment;
import com.daocao.jy.fragment.MyInviteFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 17-12-8.
 */

public class InviteFriendActivity extends BaseActivity {
    @BindView(R.id.btn_back)
    ImageView btnBack;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.pager)
    ViewPager pager;
    @BindView(R.id.tablayout)
    TabLayout tablayout;


    private Unbinder unbiner;
    private MyInviteFragment myInvite;
    private MyCommissionFragment myCommission;
    private CommissionOrderFragment commissionoOrder;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_invite_friend);
        initBar();
        unbiner = ButterKnife.bind(this);
        init();
    }

    private void init() {
        txtTitle.setText("邀请好友赚佣金");
        myInvite = new MyInviteFragment();
        myCommission = new MyCommissionFragment();
        commissionoOrder = new CommissionOrderFragment();
        Fragment[] fragments = {commissionoOrder, myInvite, myCommission};
        String[] titles=new String[]{"佣金排行榜","我的邀请","我的佣金"};
        pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }

            @Override
            public Fragment getItem(int position) {
                return fragments[position];
            }

            @Override
            public int getCount() {
                return fragments.length;
            }
        });
        tablayout.setupWithViewPager(pager);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbiner.unbind();
        unbiner = null;
    }
}
